/*-------------------------------------------------------------------------------------------------------------------------
	Player Info
-------------------------------------------------------------------------------------------------------------------------*/

local PLUGIN = {}
PLUGIN.Title = "Player Info"
PLUGIN.Description = "When players join, show info about them."
PLUGIN.Author = "Overv"
PLUGIN.ChatCommand = nil

function PLUGIN:ShowPlayerInfo( ply )
	local first = !ply:GetProperty( "nick" )
	
	if ( first ) then		
		ply:SetProperty( "unique_id", ply:UniqueID() )
		ply:SetProperty( "nick", ply:Nick() )
		ply:SetProperty( "steamid", ply:SteamID() )
		ply:SetProperty( "ip", ply:IPAddress() )
		ply:SetProperty( "LastOnline", os.time() )
		ply:SetProperty( "playtime", 0 )
		ply:SetProperty( "rank", "guest")
		ply:SetProperty( "banned", 0)
		
	else
		ply:SetProperty( "LastOnline", os.time() )
		ply:SetProperty( "nick", ply:Nick() )
		ply:SetProperty( "ip", ply:IPAddress() )
		if ( !ply:GetProperty( "playtime" ) ) then ply:SetProperty( "PlayTime", 0 ) end
		
	end
	



end

function PLUGIN:PlayerInitialSpawn( ply )
	ply.EV_IntroductionPending = true
end

function PLUGIN:PlayerSpawn( ply )
	if ( ply.EV_IntroductionPending ) then
		self:ShowPlayerInfo( ply )
		ply.EV_IntroductionPending = false
	end
end

function PLUGIN:PlayerDisconnected( ply, cmd, args )
	ply:SetProperty( "playtime", ply:GetProperty( "playtime" ) + ply:TimeConnected() )
ply:SetProperty( "lastpnline", os.time() )
end

evolve:RegisterPlugin( PLUGIN )